package com.lj.map.capability;

import com.lj.map.capability.base.HashMapKey;
import com.lj.map.capability.base.ThreadBean;
import java.util.Hashtable;
import java.util.Map;

/**
 * 测试hashTable性能
 * Created by yangsp1 on 16/3/31.
 */
public class HashTableTest {
    public static void main(String args[]) {
        long start = System.currentTimeMillis();
        //线程非安全
        Map map = new Hashtable();
        Thread t1 = new ThreadBean(map, "t1",null);
        Thread t2 = new ThreadBean(map, "t2",null);
        Thread t3 = new ThreadBean(map, "t3",null);
        t1.start();
        t2.start();
        t3.start();

        //等待所有线程执行结束
        while (true) {
            if (HashMapKey.threadExcedCnt.intValue() == 3) {
                break;
            }
        }
        long end = System.currentTimeMillis();
        System.out.println("hashTable 3个并发执行时间：" + (end - start) + "毫秒");
    }
}
